package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author 东哥
 * @since 2024-08-26
 */
@Api(tags = "点赞业务相关接口")
@RestController
@RequestMapping("/likes")
@RequiredArgsConstructor
public class LikedRecordController {
    private final ILikedRecordService recordService;
    /**
     * 1、点赞或者取消点赞 （Day6 - 随堂1）
     * @param recordFormDTO
     */
    @PostMapping
    @ApiOperation("点赞或者取消点赞")
    public void likeOrUnLike(@Valid @RequestBody LikeRecordFormDTO recordFormDTO){
        recordService.likeOrUnLike(recordFormDTO);
    }

    /**
     * 2、根据业务ID集合查询点赞状态（Day6 - 随堂2）
     * @param bizIds 待检测业务ID集合
     * @return 已点赞的业务ID集合
     */
    @GetMapping("list")    // localhost:8091/likes/list?ibizIds=1,2,3,4,5
    @ApiOperation("根据业务ID集合查询点赞状态")
    public Set<Long> isLiked(@RequestParam("bizIds") List<Long> bizIds){
        return recordService.isLiked(bizIds);
    }



}
